package A01File;

import java.io.File;

public class FileTest02 {
    public static void main(String[] args) {
        System.out.println(FindAvi());
        //File file = new File("C:\\");
        //FindAvi(file);
    }
    public static long FindAvi(){
        int count = 0;
        File[] files = File.listRoots();
        for (File file : files) {
            count += FindAvi(file);
        }
        return count;
    }
    public static long FindAvi(File file){
        int count = 0;
        File[] files = file.listFiles();
        if(files != null){
            for (File file1 : files) {
                if(file1.isFile() ){
                    String name = file1.getName();
                    if(name.endsWith(".png")){
                        System.out.println(file1);
                        count++;
                    }
                }else {
                    count += FindAvi(file1);
                }
            }
        }
        return count;
    }
}
